<?php
/**
 * 网管管理类
 *
 * @auther 大耳牛
 * 2016-12-31
 **/
namespace Xijie\Model;
use Think\Model;
class BluetoothModel extends Model{
	//定义表名称
	protected $tableName = 'bluetooth';
	
	/**
	 * 根据ID获取详情
	 **/
	public function getBluetoothInfoById($id){
		return $this->where(array(
			'blue_id' => $id
		))->find();
	}
	
	/**
	 * 获取列表
	 **/
	public function getBluetoothListByWhere($page, $where=array()){
		return $this->where($where)->order('blue_id asc')->page($page, C('PAGE_SIZE'))->select();
	}
	
	/**
	 * 获取总数
	 **/
	public function getBluetoothListCount($where=array()){
		return $this->where($where)->count();
	}
	
	/**
	 * 编辑信息
	 **/
	public function editBluetoothInfoById($id, $data){
		return $this->where(array(
			'blue_id' => $id
		))->setField($data);
	}
	
	/**
	 * 添加数据
	 **/
	public function addBluetoothInfo($data){
		return $this->data($data)->add();
	}
	
	public function getAllBluetooth(){
		return $this->order('blue_id asc')->select();
	}
	
	/**
	 * 获取人员详情
	 **/
	public function getInspectingInfoById($id){
		return M('inspecting')->where(array(
			'insp_id' => $id
		))->find();
	}
	
	public function getInspectingListCountByWhere($where){
		return M('inspecting')->where($where)->count();
	}
	
	public function getInspectingListByWhere($page, $where){
		return M('inspecting')->where($where)->order('insp_id asc')->page($page, C('PAGE_SIZE'))->select();
	}
	
	public function addInspectingInfo($data){
		return M('inspecting')->data($data)->add();
	}
	
	public function editInspectingInfo($id, $data){
		return M('inspecting')->where(array(
			'insp_id' => $id
		))->setField($data);
	}
	
	public function getLogsListCountByWhere($where){
		return M('bluetooth_log')->where($where)->count();
	}
	
	public function getLogsListByWhere($page, $where){
		return M('bluetooth_log')->where($where)->order('createtime desc')->page($page, C('PAGE_SIZE'))->select();
	}
	
}